﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.ZY
{
    class Class9
    {
        public void Calc200(IPolicyPeriodActing ppa, IDutyActing da)
        {
            int h = ppa.PolicyActing.Policy.PaymentPeriodLength;
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故") && !ppa.IsCurrentFinish)
            {
                if (ppa.Period < h)
                {
                    da.Value = ppa.Amount > ppa.TotalFee ? ppa.Amount : ppa.TotalFee;
                    ppa.IsCurrentFinish = true;

                }
                else
                {


                    //从第一期到87岁每隔一年保额的10%加88岁的支付的10%
                    int c = ppa.PolicyActing.PeriodActings.Count(q => q.Period > ppa.Period && q.Age <= 87);

                    double p1 = ppa.PolicyActing.Policy.Amount * 0.1;

                    double s = c / 2 * p1 + p1;

                    da.Value = ppa.Amount + s;
                    ppa.IsCurrentFinish = true;
                }
            }
        }

        public void Calc200(IPolicyPeriodActing ppa, IDutyActing da)
        {
            int x = ppa.PolicyActing.PeriodActings.Count() - ppa.PolicyActing.Policy.PaymentPeriodLength ;

            

            if (ppa.Period ==ppa.PolicyActing.PeriodActings.Count()-1)
            {
                da.Value = ppa.Amount * 1.6;
                da.Description = "支付160%保险金额，合同结束";
            }
        }

        public void Calc200(IPolicyPeriodActing ppa, IDutyActing da)
        {

            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                if (ppa.IsAtPaymentPeriod)
                {
                    da.Value = ppa.Amount * 0.05;                        //设置赔偿金
                    ppa.IsCurrentFinish = true;          //设置终止期
                }
            }
        }

    }
}
